Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nan2 #72

Closed
wants to merge 5 commits into from
Closed

Nan2 #72

wants to merge 5 commits into from

Conversation

sonnyp
Copy link
Contributor

@sonnyp sonnyp commented Sep 21, 2015

WIP; could use some help


target->Set(NanNew<String>("StringPrep"), t->GetFunction());
target->Set(Nan::New<String>("StringPrep").ToLocalChecked(), t->GetFunction());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this correct?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

correct but you should use Nan::Set(target, Nan::New<String>("StringPrep").ToLocalChecked(), t->GetFunction()); now for max-compatibility

@sonnyp sonnyp mentioned this pull request Sep 21, 2015
@austinkelleher
Copy link

+1 Need this very much. Looking to moving to Node 4.1.0.

@philidem
Copy link

👍

@erulabs
Copy link

erulabs commented Sep 24, 2015

👍 as well! Thank you for your efforts!

@lloydwatkin
Copy link
Contributor

@rvagg is usually very helpful with nan stuff if we ask nicely... please? :)

@erulabs
Copy link

erulabs commented Sep 28, 2015

@sonnyp I've started another effort here: #74

@austinkelleher
Copy link

The Nan2 support that @erulabs has started is looking pretty good so far.

@@ -43,11 +43,11 @@ class StringPrep : public ObjectWrap {

static NAN_METHOD(New)
{
NanScope();
Nan::HandleScope scope;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can be removed from inside all NAN_*() methods

@lloydwatkin
Copy link
Contributor

You rule @rvagg, thanks!

NanScope();
Local<FunctionTemplate> t = NanNew<FunctionTemplate>(New);
Nan::HandleScope scope;
Local<FunctionTemplate> t = Nan::New<FunctionTemplate>(New);
NanAssignPersistent(stringprep_constructor, t);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

../node-stringprep.cc: In static member function ‘static void StringPrep::Initialize(v8::Handle<v8::Object>)’:

../node-stringprep.cc:24:50: error: ‘NanAssignPersistent’ was not declared in this scope

     NanAssignPersistent(stringprep_constructor, t);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stringprep_constructor needs to be declared as a Nan::Persistent now (instead of just Persistent, i.e. v8::Persistent) and then you use stringprep_constructor.Reset(t) here

@sonnyp sonnyp mentioned this pull request Sep 29, 2015
{
Nan::EscapableHandleScope scope
size_t destLen = str.length() + 1;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

../node-stringprep.cc: In member function ‘v8::Local<v8::Value> StringPrep::prepare(v8::String::Value&)’:

../node-stringprep.cc:115:5: error: expected initializer before ‘size_t’

     size_t destLen = str.length() + 1;

@sonnyp
Copy link
Contributor Author

sonnyp commented Sep 29, 2015

@rvagg thanks a lot for the help

I ported @erulabs work from #74 and your comments here.

I added the last build errors as comments. Additionally if you could double check the PR that would be great.

@erulabs
Copy link

erulabs commented Sep 29, 2015

Hey @sonnyp looks like a missing semicolon on line #114

The remaining issue seems to be how we return the value (lines 228 & 279):

Local result = Nan::New(dest, destLen).ToLocalChecked();
info.GetReturnValue().Set(result);

This passes tests, but appears to break the unicode/ascii conversion. I tried a handful of ideas without much results. +1 to big big thanks to @rvagg 💃

@sonnyp
Copy link
Contributor Author

sonnyp commented Sep 30, 2015

@erulabs

../node-stringprep.cc: In function ‘Nan::NAN_METHOD_RETURN_TYPE ToUnicode(Nan::NAN_METHOD_ARGS_TYPE)’:

../node-stringprep.cc:228:11: error: missing template arguments before ‘result’

     Local result = Nan::New(dest, destLen).ToLocalChecked();

           ^

../node-stringprep.cc:228:11: error: expected ‘;’ before ‘result’

../node-stringprep.cc:230:31: error: ‘result’ was not declared in this scope

     info.GetReturnValue().Set(result);

https://github.com/node-xmpp/node-stringprep/pull/72/files#diff-4e17e0441c265ec99c496bc09f563bc2R228

@erulabs
Copy link

erulabs commented Sep 30, 2015

Yeah - it should be a Local for sure, which builds properly, but breaks the actual tests. I get the feeling that something here is breaking our unicode/ascii converstion

@erulabs
Copy link

erulabs commented Oct 5, 2015

I wonder if we can reach out to the original authors of node-stringprep.cc and see if they have some advice for us since it seems like we've hit a dead end :(
@pixelglow @dodo @lloydwatkin I hope this isn't bothersome - any pointers to help us convert to NAN2 without breaking the package would be hugely appreciated :) Thanks!

@lloydwatkin
Copy link
Contributor

Actually @astro is the original creator AFAIK, I've just been keeping it ticking over. I'm afraid native module binding isn't something I'm familiar with.

@sonnyp
Copy link
Contributor Author

sonnyp commented Oct 6, 2015

As far as node-xmpp is concerned I don't think we should spend much time on node-stringprep. RFC 7622 deprecates the use of stringprep see https://github.com/node-xmpp/JID/issues/1

I have made a standalone and stringprep-free module for JID at https://github.com/node-xmpp/JID and plan to use it in node-xmpp-core see https://github.com/node-xmpp/node-xmpp-core/pull/76 . (Somehow all original tests passes without stringprep)

I understand it's not fully compliant but neither is node-xmpp-core JID anyway ( + other issues such as memory leaks and native module burden).

I plan to work on RFC 7622 compliance next.

@ChALkeR
Copy link

ChALkeR commented Apr 21, 2016

Tracking: nodejs/node#2798

@astro
Copy link
Collaborator

astro commented May 6, 2016

Fixed by #79

@astro astro closed this May 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

8 participants